{% extends 'base.html' %}

{% block title %}错题导出预览{% endblock %}

{% block content %}
<div class="container mx-auto px-4 py-8">
    <h1 class="text-2xl font-bold mb-6">错题导出预览</h1>

    <div class="card shadow mb-6">
        <div class="card-header bg-primary text-white">
            <h5 class="mb-0">已选择 {{ mistakes|length }} 道错题</h5>
        </div>
        <div class="card-body">
            <form method="post" action="{% url 'core:mistake_export_preview' %}">
                {% csrf_token %}
                <input type="hidden" name="mistake_ids" value="{{ mistake_ids }}">

                <div class="list-group mb-4">
                    {% for mistake in mistakes %}
                    <div class="list-group-item">
                        <h5 class="mb-1">{{ mistake.title }}</h5>
                        <p class="mb-1"><strong>学科:</strong> {{ mistake.subject.name }} | <strong>章节:</strong> {{ mistake.chapter.name }} | <strong>知识点:</strong> {{ mistake.knowledge_point.name }}</p>
                        <small class="text-muted">星级: {{ mistake.star_rating }} ★ | 引用: {{ mistake.citation_count }}</small>
                        {% if mistake.question %}
                        <div class="mt-3">
                            <h6 class="text-primary">问题:</h6>
                            <div class="text-break">{{ mistake.question|safe }}</div>
                        </div>
                        {% endif %}
                        {% if mistake.answer %}
                        <div class="mt-3">
                            <h6 class="text-success">答案:</h6>
                            <div class="text-break">{{ mistake.answer|safe }}</div>
                        </div>
                        {% endif %}
                    </div>
                    {% empty %}
                    <div class="list-group-item text-center text-muted">未选择任何错题</div>
                    {% endfor %}
                </div>

                <div class="d-flex justify-content-between">
                    <a href="javascript:history.back()" class="btn btn-outline-secondary">返回</a>
                    <button type="submit" class="btn btn-primary">确认导出到Word</button>
                </div>
            </form>
        </div>
    </div>
</div>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            if (window.MathJax) {
                MathJax.typeset();
            }
        });
    </script>
{% endblock %}